package br.com.fidalgotecnologia.layar.data;

import java.util.List;

import javax.persistence.EntityManager;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import br.com.fidalgotecnologia.core.data.abs.BaseDAO;
import br.com.fidalgotecnologia.layar.entity.HotSpot;

public class HotSpotDAO extends BaseDAO<HotSpot>{
	
	public static HotSpotDAO instance;
	
	public static HotSpotDAO getInstance() {
		if(instance==null){
			instance = new HotSpotDAO();
		}
		return instance;
	}
	
	@Override
	public Class<HotSpot> getClasse() {
		// TODO Auto-generated method stub
		return HotSpot.class;
	}

	public HotSpot buscarHotSpot(HotSpot hotSpot) {
		HotSpot retorno = null;
		try {
			beginUserTransaction();
		
		EntityManager em = getEntityManager();
	    Session session = (Session)em.getDelegate();
	    session.beginTransaction();
	    Criteria criteria = session.createCriteria(getClasse());
	    criteria.add(Restrictions.eq("id",hotSpot.getId()));
	    retorno =(HotSpot)criteria.uniqueResult();
	    session.getTransaction().commit();
	    commitUserTransaction();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    return retorno;
	}

}
